package delegate

interface Base {
    fun print()
}

class BaseImpl(val x: Int) : Base {

    override fun print() {
        print(x)
    }

}




class Derived(b: Base) : Base by b



object DerivedWithoutBy: Base {
    private var instance: Base = this
    fun setBase(b: Base) {
        instance = b
    }

    override fun print() {
        instance.print()
    }
}

fun main() {
    val b = BaseImpl(10)
    DerivedWithoutBy.setBase(b)
    DerivedWithoutBy.print()
}


